<?php
include("configado.php");

// Query from mySQL
$dbO = NewADOConnection(__DBTYPE__);
$dbN = NewADOConnection(__DBTYPE__);
$dbO->debug = true;
$dbN->debug = true;
$dbO->NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';
$dbN->NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';

$dbO->Connect( __DBHOST__, __DBUSER__, __DBPASSWD__, __DBNAME__);
$dbN->Connect( __DBHOST__1, __DBUSER__1, __DBPASSWD__1, __DBNAME__1);


$dbO->Execute( 'set names latin1' );

/*
$sql = "select day_in, no, kinds, location_name, problem, solution, whonote, status, cost, savesolution from detail";
$pager = new ADODB_Pager($dbO,$sql); 
$pager->Render($rows_per_page=5); 
*/
//$lastmonth = date("Ym",mktime(0, 0, 0, date("m")-2, date("d"),   date("Y")));//

//echo $lastmonth;


$sql = "select day_in, no, kinds, location_name, problem, solution, whonote, status, cost, savesolution from detail";
$rs = $dbO->Execute($sql);
//print_r($rs);

while($arr = $rs->FetchRow()) {
	echo "<pre>";
	print_r($arr);
			
	echo "</pre>";
	
	$sql = "insert into detail (day_in, no, fault_type, location_id, problem, solution, username_note, status, cost, username_process ) ";
	$sql .="values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
	$smtp = $dbN->Prepare($sql);
	$arr_in = array($arr['day_in'], $arr['no'], $arr['kinds'], $arr['location_name'], $arr['problem'], $arr['solution'], $arr['whonote'], $arr['status'], $arr['cost'], $arr['savesolution']);
	
	if($dbN->Execute($smtp, $arr_in)){
		echo "input success..<br />";
	}else{
		echo "error.. <br />";
	}
	
}

$dbO->close();
$dbN->close();

?>